package com.machine.filling.Test;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.google.zxing.WriterException;
import com.machine.filling.MyApp;
import com.machine.filling.R;
import com.machine.filling.db.dao.ClientInfoDao;
import com.machine.filling.db.dao.GunInfoDao;
import com.machine.filling.db.modle.ClientInfoModle;
import com.machine.filling.net.http.network.APIHttpManager;
import com.machine.filling.net.http.network.BaseHttpStringCallback;
import com.machine.filling.net.ws.req.WsGetErWeiMaReq;
import com.machine.filling.net.ws.response.WsResGetCardFuelingOrder;
import com.machine.filling.net.ws.response.WsResGetErWeiMa;
import com.machine.filling.net.ws.response.WsResPayByCard;
import com.machine.filling.net.ws.response.WsResPayByCash;
import com.machine.filling.util.DateUtils;
import com.machine.filling.util.DeviceUtils;
import com.machine.filling.util.ErWeiMaUtils;
import com.machine.filling.util.SpUtils;
import com.machine.filling.util.StringUtil;

import okhttp3.Call;

/**
 * Created by Administrator on 2018/3/15 0015.
 */
@Deprecated
public class TestHttpFragment extends Fragment implements View.OnClickListener {

    private TextView tv_res;
    private String respMsg;
    private String cardFuelOrderNum;
    private ImageView iv_ewm;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(getContext(), R.layout.fg_test, null);
        initView(view);
        initData();
        return view;
    }


    private void initView(View view) {
        view.findViewById(R.id.bt_login).setOnClickListener(this);
        view.findViewById(R.id.bt_station_info).setOnClickListener(this);
        view.findViewById(R.id.bt_machine_list).setOnClickListener(this);
        view.findViewById(R.id.bt_bind).setOnClickListener(this);
        view.findViewById(R.id.bt_unbind).setOnClickListener(this);
        view.findViewById(R.id.bt_type_list).setOnClickListener(this);
        view.findViewById(R.id.bt_tank_list).setOnClickListener(this);
        view.findViewById(R.id.bt_gun_list).setOnClickListener(this);
        view.findViewById(R.id.bt_gun_detail).setOnClickListener(this);
        view.findViewById(R.id.bt_add_gun).setOnClickListener(this);
        view.findViewById(R.id.bt_modify_gun).setOnClickListener(this);
        view.findViewById(R.id.bt_del_gun).setOnClickListener(this);
        view.findViewById(R.id.bt_over).setOnClickListener(this);
        view.findViewById(R.id.bt_get_top_guns).setOnClickListener(this);
        view.findViewById(R.id.bt_get_card_info).setOnClickListener(this);
        view.findViewById(R.id.bt_get_pre_order).setOnClickListener(this);
        view.findViewById(R.id.bt_update_state).setOnClickListener(this);
        view.findViewById(R.id.bt_check_version).setOnClickListener(this);

        view.findViewById(R.id.bt_create_order).setOnClickListener(this);
        view.findViewById(R.id.bt_commit_order).setOnClickListener(this);
        view.findViewById(R.id.bt_query_order).setOnClickListener(this);
        view.findViewById(R.id.bt_pay_by_cash).setOnClickListener(this);
        view.findViewById(R.id.bt_pay_by_card).setOnClickListener(this);
        view.findViewById(R.id.bt_get_ad_list).setOnClickListener(this);
        view.findViewById(R.id.bt_back).setOnClickListener(this);
        view.findViewById(R.id.bt_get_ewm).setOnClickListener(this);


        iv_ewm = view.findViewById(R.id.iv_ewm);

        tv_res = (TextView) view.findViewById(R.id.tv_res);
        respMsg = "";
        tv_res.setText(respMsg);
    }

    private void initData() {

    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {
            case R.id.bt_back:
                TestMainFragment testMainFragment =  new TestMainFragment();
                testMainFragment.setChangeFg(new TestMainFragment.ChangeFg() {
                    @Override
                    public void changeHttp(FragmentActivity activity) {
                        activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout4,new TestHttpFragment()).commit();
                    }

                    @Override
                    public void changePort(FragmentActivity activity) {
                        activity.getSupportFragmentManager().beginTransaction().replace(R.id.framelayout4,new TestPortFragment()).commit();
                    }
                });
                getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.framelayout4,testMainFragment).commit();
                break;
            case R.id.bt_login:
                bt_login();
                break;
            case R.id.bt_station_info:
                bt_station_info();
                break;
            case R.id.bt_machine_list:
                bt_machine_list();
                break;
            case R.id.bt_bind:
                bt_bind();
                break;
            case R.id.bt_unbind:
                bt_unbind();
                break;
            case R.id.bt_type_list:
                bt_type_list();
                break;
            case R.id.bt_tank_list:
                bt_tank_list();
                break;
            case R.id.bt_gun_list:
                bt_gun_list();
                break;
            case R.id.bt_gun_detail:
                bt_gun_detail();
                break;
            case R.id.bt_add_gun:
                bt_add_gun();
                break;
            case R.id.bt_modify_gun:
                bt_modify_gun();
                break;
            case R.id.bt_del_gun:
                bt_del_gun();
                break;
            case R.id.bt_over:
                bt_over();
                break;
            case R.id.bt_get_top_guns:
                bt_get_top_guns();
                break;
            case R.id.bt_get_card_info:
                bt_get_card_info();
                break;
            case R.id.bt_get_pre_order:
                bt_get_pre_order();
                break;
            case R.id.bt_update_state:
                bt_update_state();
                break;
            case R.id.bt_check_version:
                bt_check_version();
                break;

            case R.id.bt_create_order://油卡加油 创建订单
                cardFuelOrderNum = StringUtil.createOrderNum();
                bt_create_order(cardFuelOrderNum);
                break;
            case R.id.bt_commit_order:
                bt_commit_order();
                break;
            case R.id.bt_query_order:
                bt_query_order();
                break;
            case R.id.bt_pay_by_cash://现金支付
                bt_pay_by_cash();
                break;
            case R.id.bt_pay_by_card://油卡支付
                bt_pay_by_card(cardFuelOrderNum);
                break;
            case R.id.bt_get_ad_list:
                bt_get_ad_list();
                break;
            case R.id.bt_get_ewm://获取二维码
                bt_get_ewm();
                break;
        }
    }

    /**
     * 获取二维码进行支付
     */
    private void bt_get_ewm() {
        respMsg += "\n\n获取二维码进行支付\n";
        ClientInfoModle modle = ClientInfoDao.getInstance().getModleByDeviceNum();
        String orderNum = "123456";
        APIHttpManager.getInstance().getErWeiMa(modle.getToken(),orderNum, modle.getStationId(), modle.getMachineId(), new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                WsResGetErWeiMa bean = new Gson().fromJson(result,WsResGetErWeiMa.class);

                respMsg += result;
                tv_res.setText(respMsg);
                if (bean != null) {
                    try {
                        Bitmap code = ErWeiMaUtils.getInstance().createCode(bean.getQrCodeUrl(), BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
                        Glide.with(TestHttpFragment.this).load(code).into(iv_ewm);
                    } catch (WriterException e) {
                        e.printStackTrace();
                    }
                }
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 登录
     */
    private void bt_login() {
        respMsg += "\n\n登录\n";
        tv_res.setText(respMsg);
        APIHttpManager.getInstance().login(TestCommon.login_name, TestCommon.login_psw, "7ec970785a09def6", new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油站信息
     */
    private void bt_station_info() {
        respMsg += "\n\n获取油站信息\n";
        APIHttpManager.getInstance().getOilStationInfo(TestCommon.station_num, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油机列表
     */
    private void bt_machine_list() {
        respMsg += "\n\n获取油机列表\n";
        APIHttpManager.getInstance().getOilMachineList(TestCommon.station_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 绑定油机与终端
     */
    private void bt_bind() {
        respMsg += "\n\n绑定油机与终端\n";
        APIHttpManager.getInstance().bindClientAndOilMachine(TestCommon.station_id,
                TestCommon.machine_id, TestCommon.device_id, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                        ClientInfoDao.getInstance().deleteAll();
                        GunInfoDao.getInstance().deleteAll();
                        SpUtils.getInstance(MyApp.getInstance()).setInitComplete(false);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 解绑油机与终端
     */
    private void bt_unbind() {
        respMsg += "\n\n解绑油机与终端\n";
        APIHttpManager.getInstance().reSetOilClient(TestCommon.station_id,
                TestCommon.machine_id, TestCommon.device_id, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 获取油品列表
     */
    private void bt_type_list() {
        respMsg += "\n\n获取油品列表\n";
        APIHttpManager.getInstance().getOilTypeList(TestCommon.station_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油罐列表
     */
    private void bt_tank_list() {
        respMsg += "\n\n获取油罐列表\n";
        APIHttpManager.getInstance().getOilTankList(TestCommon.station_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油枪列表
     */
    private void bt_gun_list() {
        respMsg += "\n\n获取油枪列表\n";
        APIHttpManager.getInstance().getOilGunList(TestCommon.machine_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油枪详情
     */
    private void bt_gun_detail() {
        respMsg += "\n\n获取油枪详情\n";
        APIHttpManager.getInstance().getOilGunDetail(TestCommon.gunId, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 添加油枪
     */
    private void bt_add_gun() {
        respMsg += "\n\n添加油枪\n";
        APIHttpManager.getInstance().addOilGunInfo(TestCommon.station_id, TestCommon.machine_id, TestCommon.tankId,
                "123"/*TestCommon.gunNum*/, "右侧枪"/*TestCommon.gunName*/, 11.1 + "", "ttyS1"/*TestCommon.serialNum*/, TestCommon.typeId, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 修改油枪
     */
    private void bt_modify_gun() {
        respMsg += "\n\n修改油枪\n";
        APIHttpManager.getInstance().modifyOilGunInfo(TestCommon.gunId, TestCommon.machine_id, TestCommon.tankId, TestCommon.gunNum,
                "范2", "110", TestCommon.serialNum, TestCommon.typeId, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 删除油枪
     */
    private void bt_del_gun() {
        respMsg += "\n\n删除油枪\n";
        APIHttpManager.getInstance().delGun(TestCommon.gunId, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 终端初始化完成
     */
    private void bt_over() {
        respMsg += "\n\n终端初始化完成\n";
        APIHttpManager.getInstance().getToken(TestCommon.station_id, TestCommon.machine_id, TestCommon.machine_num, TestCommon.device_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取首页油枪详情
     */
    private void bt_get_top_guns() {
        respMsg += "\n\n获取首页油枪详情\n";
        APIHttpManager.getInstance().getTopGunsInfo(TestCommon.token, TestCommon.machine_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取油卡信息
     */
    private void bt_get_card_info() {
        respMsg += "\n\n获取油卡信息\n";
        APIHttpManager.getInstance().getCardInfo(
                TestCommon.token,
                TestCommon.machine_id,
                TestCommon.gunId, TestCommon.cardNum, TestCommon.eneryCardNum, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 获取预约订单
     */
    private void bt_get_pre_order() {
        respMsg += "\n\n获取预约订单\n";
        APIHttpManager.getInstance().getPreOrderInfo(TestCommon.token, TestCommon.station_id,
                TestCommon.gunId, TestCommon.preOrderNum, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 更新油枪状态
     */
    private void bt_update_state() {
        respMsg += "\n\n更新油枪状态\n";
        APIHttpManager.getInstance().updateGunState(TestCommon.token, TestCommon.gunId, "1", new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 检测版本号
     */
    private void bt_check_version() {
        respMsg += "\n\n检测版本号\n";
        APIHttpManager.getInstance().checkeAPKVersion(TestCommon.token, TestCommon.machine_id, new BaseHttpStringCallback() {
            @Override
            public void onSuccess(Call call, String result) {
                respMsg += result;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFailed(String errorCode, String errorMsg, Exception exception) {
                respMsg += errorMsg;
                tv_res.setText(respMsg);
            }

            @Override
            public void onFinished() {

            }
        });
    }

    /**
     * 创建订单
     * @Params cardFuleOrderNum 油卡加油的订单编号
     */
    private void bt_create_order(String cardFuleOrderNum) {
        respMsg += "\n\n创建订单\n";
        APIHttpManager.getInstance().createNewOrder(TestCommon.token,
                TestCommon.cuPrice, TestCommon.machine_num, "0",cardFuleOrderNum , TestCommon.tankId,
                TestCommon.gunNum, TestCommon.gunId,
                TestCommon.station_id, TestCommon.machine_id, TestCommon.cardId,TestCommon.price, "1",
                TestCommon.typeName, TestCommon.typeId, TestCommon.cuPrice, TestCommon.tankNum,"1",
                Integer.parseInt(SpUtils.getInstance(getContext()).getPingZhengHao(), 16) + "", DateUtils.getCurrentTimeYMDHMS(),
                new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 提交预约订单
     */
    private void bt_commit_order() {
        respMsg += "\n\n提交预约订单\n";
        APIHttpManager.getInstance().caretePreOrder(TestCommon.token, TestCommon.preOrderNum, TestCommon.gunId,
                TestCommon.machine_id, TestCommon.tankId, TestCommon.gunNum, TestCommon.typeId, "11", "1",
                "1", TestCommon.machine_num, TestCommon.typeName, "1", TestCommon.tankNum,
                SpUtils.getInstance(this.getContext()).getPingZhengHao(),"1",DateUtils.getCurrentTimeYMDHMS(),new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 查找订单
     */
    private void bt_query_order() {
        respMsg += "\n\n查找订单\n";
        APIHttpManager.getInstance().getCardFuelingOrder(TestCommon.token, TestCommon.machine_id,
                TestCommon.orderNum, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        WsResGetCardFuelingOrder bean = new Gson().fromJson(result,WsResGetCardFuelingOrder.class);
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 现金支付
     */
    private void bt_pay_by_cash() {
        respMsg += "\n\n现金支付\n";
        APIHttpManager.getInstance().payByCash(TestCommon.token, TestCommon.machine_id,
                TestCommon.orderNum, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        WsResPayByCash bean = new Gson().fromJson(result,WsResPayByCash.class);
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }
    /**
     * 油卡支付
     */
    private void bt_pay_by_card(String orderNum) {
        respMsg += "\n\n油卡支付\n";
        APIHttpManager.getInstance().payByCard(TestCommon.token, TestCommon.machine_id,
                orderNum, new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        WsResPayByCard bean = new Gson().fromJson(result,WsResPayByCard.class);
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }

    /**
     * 获取广告列表
     */
    private void bt_get_ad_list(){
        respMsg += "\n\n获取广告列表\n";
        APIHttpManager.getInstance().getAdList(TestCommon.token, TestCommon.machine_id,
                 new BaseHttpStringCallback() {
                    @Override
                    public void onSuccess(Call call, String result) {
                        respMsg += result;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFailed(String errorCode, String errorMsg, Exception exception) {
                        respMsg += errorMsg;
                        tv_res.setText(respMsg);
                    }

                    @Override
                    public void onFinished() {

                    }
                });
    }
}
